package com.study.util;

import com.study.common.ListNode;
import com.study.common.TreeNode;

/**
 * @author 大硕
 * 2019-03-31 1:00 PM
 **/
@SuppressWarnings("all")
public class SwapUtil {

    @SuppressWarnings("all")
    public static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

    @SuppressWarnings("all")
    public static void swap(int[] pre, int[] cur) {
        int[] tmp = pre;
        pre = cur;
        cur = tmp;
    }

    @SuppressWarnings("all")
    public static void swap(char[] c, int i, int j) {
        char temp = c[i];
        c[i] = c[j];
        c[j] = temp;
    }

    @SuppressWarnings("all")
    public static void swap(TreeNode root) {
        TreeNode tmp = root.left;
        root.left = root.right;
        root.right = tmp;
    }

    @SuppressWarnings("all")
    public static void swap(TreeNode t1, TreeNode t2) {
        int temp = t1.val;
        t1.val = t2.val;
        t2.val = temp;
    }

    @SuppressWarnings("all")
    public static void swap(ListNode left, ListNode right) {
        int tmp = left.val;
        left.val = right.val;
        right.val = tmp;
    }

}